home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / sgwnd10 / comboite.cls < prev    next >
Encoding:
Visual Basic class definition  |  1998-07-01  |  1.8 KB  |  81 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "ComboItems"
  6. Attribute VB_GlobalNameSpace = False
  7. Attribute VB_Creatable = False
  8. Attribute VB_PredeclaredId = False
  9. Attribute VB_Exposed = True
  10. Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
  11. Attribute VB_Ext_KEY = "Top_Level" ,"No"
  12. Attribute VB_Ext_KEY = "Collection" ,"ComboItem"
  13. Attribute VB_Ext_KEY = "Member0" ,"ComboItem"
  14. Option Explicit
  15.  
  16. 'local variable to hold collection
  17. Private mCol As Collection
  18. Public Function Add(Key As String, Optional sKey As String) As ComboItem
  19.     'create a new object
  20.     Dim objNewMember As ComboItem
  21.     Set objNewMember = New ComboItem
  22.  
  23.  
  24.     'set the properties passed into the method
  25.     objNewMember.Key = Key
  26.  
  27.  
  28.  
  29.  
  30.     If Len(sKey) = 0 Then
  31.         mCol.Add objNewMember
  32.     Else
  33.         mCol.Add objNewMember, sKey
  34.     End If
  35.  
  36.  
  37.     'return the object created
  38.     Set Add = objNewMember
  39.     Set objNewMember = Nothing
  40.  
  41.  
  42. End Function
  43.  
  44. Public Property Get Item(vntIndexKey As Variant) As ComboItem
  45. Attribute Item.VB_UserMemId = 0
  46.   Set Item = mCol(vntIndexKey)
  47. End Property
  48.  
  49.  
  50.  
  51. Public Property Get Count() As Long
  52.     Count = mCol.Count
  53. End Property
  54.  
  55.  
  56. Public Sub Remove(vntIndexKey As Variant)
  57.     mCol.Remove vntIndexKey
  58. End Sub
  59.  
  60.  
  61. Public Property Get NewEnum() As IUnknown
  62. Attribute NewEnum.VB_UserMemId = -4
  63. Attribute NewEnum.VB_MemberFlags = "40"
  64.     'this property allows you to enumerate
  65.     'this collection with the For...Each syntax
  66.     Set NewEnum = mCol.[_NewEnum]
  67. End Property
  68.  
  69.  
  70. Private Sub Class_Initialize()
  71.     'creates the collection when this class is created
  72.     Set mCol = New Collection
  73. End Sub
  74.  
  75.  
  76. Private Sub Class_Terminate()
  77.     'destroys collection when this class is terminated
  78.     Set mCol = Nothing
  79. End Sub
  80.  
  81.